import Cookies from "js-cookie";

export function getNowTime() {
    const currentDate = new Date();

    const year = currentDate.getFullYear();
    const month = (currentDate.getMonth() + 1).toString().padStart(2, '0');
    const day = currentDate.getDate().toString().padStart(2, '0');
    const hour = currentDate.getHours().toString().padStart(2, '0');
    const minute = currentDate.getMinutes().toString().padStart(2, '0');
    const second = currentDate.getSeconds().toString().padStart(2, '0');

    const formattedDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;


    console.log("当前时间为：" + formattedDate);
    return formattedDate;
}

export function myThrottle(fn, wait) {
    let task = null;
    return function () {
        if (!task) {
            console.log("点击3")
            task = setTimeout(() => {
                task = null;
                fn.apply(this, arguments);
            }, wait);
        }
    }
}


export function getUnitText(unit) {
    // You can customize this method to display meaningful status text
    switch (unit.toString()) {//0天 1周(七天) 2月(30天) 3年(365天)
        case '0':
            return '天';
        case '1':
            return '周(七天)';
        case '2':
            return '月(30天)';
        case '3':
            return '年(365天)';
        default:
            return '未知状态';
    }
}

export function getLendText(status) {
    // You can customize this method to display meaningful status text
    switch (status.toString()) {//0待租 1有人想要 2已租出
        case '0':
            return '待租';
        case '1':
            return '锁定';
        case '2':
            return '租出';
        default:
            return '未知';
    }
}

export function getAgreeText(status) {
    // You can customize this method to display meaningful status text
    switch (status.toString()) {//状态 0开始 1进行中 2归还 3完成
        case '0':
            return '想要';
        case '1':
            return '进行中';
        case '2':
            return '归还';
        case '3':
            return '完成';
        default:
            return '未知';
    }
}


export function ShowToast(params) {
    // uni.$emit('ShowToast', params)
    uni.showToast({
        title: 'title',
        icon: 'none',
    })
}
